<template>
	<view>
		<view class="content" v-for="(item,index) in dataList" :key="index">
			<view class="u-p-l-30 u-p-t-30 u-p-b-10">
				<text class="u-font-24">{{item.operatorName}}</text>
			</view>
			<u-cell-group>
				<u-cell-item v-for="(cell,i) in item.list" :title="cell.name" @click="goView('/pages/admin/franchise/views/views?id='+cell.id)"></u-cell-item>
			</u-cell-group>
		</view>
		
		<tabbar :current="1"></tabbar>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	import tabbar from '../components/tabbar/tabbar.vue'
	
	export default {
		components:{
			tabbar
		},
		data() {
			return {
				dataList: []
			}
		},
		computed: {
			...mapState({
				userdetail: state => state.userdetail,
				storeId: state => state.storeId,
				franchiseId: state => state.franchiseId,
				operatorId: state => state.operatorid
			}),
			photo() {
				return this.fileURL + this.userdetail.photo
			},
			// 是否运营商管理员
			isOperatorAdmin(){
				return this.userdetail.bindinfo.operator.ismanager
			},
			// 是否加盟商管理员
			isFranchiseAdmin(){
				return this.userdetail.bindinfo.operator.franchiselist.find((item)=>item.id == this.franchiseId).ismanager
			},
			// 是否（当前）站点的管理员
			isStoreAdmin(){
				return this.userdetail.bindinfo.operator.franchiselist.find((item)=>item.id == this.franchiseId).storelist.find((item)=>item.id == this.storeId).ismanager
			}
		},
		onLoad() {
			this.$store.dispatch('getDetails').then((res) => {
				console.log('franchise/menu/menu.vue-获取用户信息',res)
				let operatorlist = [res.bindinfo?.operator]
				let dataList = []
				operatorlist.forEach((item,index)=>{
					dataList.push({
						operatorName: item.name,
						list:[]
					})
					item.franchiselist.forEach((cell)=>{
						if(cell.ismanager == true){
							dataList[index].list.push(cell)
						}
					})
				})
				this.dataList = dataList
				console.log('this.dataList',this.dataList)
			})
		},
		methods: {
			goView(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.grid-box{
		border-radius: 0;
	}
	.links{
		color: $u-color-blue;
		border-bottom: 1px solid $u-color-blue;
	}
</style>
